apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: {{ .Chart.Name }}
  name: {{ .Chart.Name }}-deployment
spec:
  replicas: 1
  revisionHistoryLimit: 3
  selector:
    matchLabels:
      app: {{ .Chart.Name }}
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      annotations:
        prometheus.io/scrape: 'true'
        prometheus.io/port: '8090'
      labels:
        app: {{ .Chart.Name }}
    spec:
      containers:
      - env:
            {{- range $name, $value := .Values.env }}
        - name: {{ $name }}
          value: {{ $value }}
            {{- end }}
        image: "{{ .Values.global.registry | default .Chart.Annotations.imageRegistry }}/{{ .Values.repository | default .Chart.Annotations.imageName }}{{- if ( .Values.digest) -}}@{{ .Values.digest }}{{- else -}}:{{ .Chart.Annotations.imageTag }}{{- end -}}"
        imagePullPolicy: Always
        name: {{ .Chart.Name }}
        ports:
        - containerPort: 8090
        - containerPort: 8443
        resources: { }
        volumeMounts:
        - name: secrets
          mountPath: /etc/secrets/
      dnsPolicy: ClusterFirst
      volumes:
      - name: secrets
        secret:
          secretName: {{.Chart.Name}}-files
      imagePullSecrets:
      {{- range .Values.global.imagePullSecrets }}
      - name: {{ . }}
      {{- end }}
      restartPolicy: Always
      {{- if .Values.global.nodeSelector }}
      nodeSelector:
      {{- range $label, $value := .Values.global.nodeSelector }}
        {{ $label }}: {{ $value }}
      {{- end }}
      {{- end }}
      serviceAccountName: default